//
//  WelcomViewController.m
//  LastTemp
//
//  Created by dllo on 15/4/30.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "WelcomViewController.h"
#import "HomePageViewController.h"
#import "AVSingleton.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height
@interface WelcomViewController ()
@property(nonatomic,retain)UIScrollView *scrollView;
@property(nonatomic,retain)UILabel *label1;
@property(nonatomic,retain)UILabel *label;
@property(nonatomic,retain)UILabel *label3;
@property(nonatomic,retain)UILabel *label4;
@property(nonatomic,retain)UIButton *button;
@end

@implementation WelcomViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blueColor];
    self.scrollView = [[UIScrollView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.view addSubview:self.scrollView];
    [_scrollView release];
    self.scrollView.contentSize = CGSizeMake(WIDTH*3, HEIGHT);
   
    
 
        UIImageView *imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
        [self.scrollView addSubview:imageView1];

        imageView1.image = [UIImage imageNamed:@"once2"];
        [imageView1 release];
     [self showWordOne];
    [UIView animateWithDuration:2 animations:^{
        self.label.alpha = 1;
        self.label1.alpha = 1;
    } completion:^(BOOL finished) {
    }];
    
    
    
    
    
    
    
//    self.button.layer.borderWidth = 3;
    
    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView2];

    imageView2.image = [UIImage imageNamed:@"once3"];
    [imageView2 release];
    [self showWordTwo];
    
    UIImageView *imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*2, 0, WIDTH, HEIGHT)];
    [self.scrollView addSubview:imageView3];

    imageView3.image = [UIImage imageNamed:@"once1"];
    [imageView3 release];
    
    
    self.view.userInteractionEnabled = YES;
    self.scrollView.pagingEnabled = YES;
    self.scrollView.delegate = self;
    
    self.button = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.scrollView addSubview:self.button];
    self.button.frame = CGRectMake(WIDTH*2, 200, WIDTH, 40);
    [self.button setTitle:@"立 即 体 验" forState:UIControlStateNormal];
    [self.button addTarget:self action:@selector(pushController) forControlEvents:UIControlEventTouchUpInside];
    self.button.titleLabel.font = [UIFont systemFontOfSize:40];
    self.button.tintColor = [UIColor whiteColor];
    
    UILabel *topLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH*2, 190, WIDTH, 3)];
    topLabel.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:topLabel];
    
    UILabel *drowLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH*2, 250, WIDTH, 3)];
    drowLabel.backgroundColor = [UIColor whiteColor];
    [self.scrollView addSubview:drowLabel];
    
    

    
    
    
}



-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{

   
   
    [UIView animateWithDuration:2 animations:^{
        self.label3.alpha = 1;
        
    } completion:^(BOOL finished) {
        [UIView animateWithDuration:1 animations:^{
            self.label4.alpha = 1;
            
        } completion:^(BOOL finished) {
        }];
    }];
    
   
   
}

- (void)showWordOne
{
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 150, WIDTH, 50)];
    [self.scrollView addSubview:self.label];
    [_label release];
    self.label.text = @"欢迎使用";
    self.label.font = [UIFont systemFontOfSize:30];
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.alpha = 0;
    
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 350, WIDTH, 50)];
    [self.scrollView addSubview:self.label1];
    [_label1 release];
    self.label1.text = @"草 莓 音 乐";
    self.label1.font = [UIFont systemFontOfSize:50];
    self.label1.textAlignment = NSTextAlignmentCenter;
    self.label1.alpha = 0;
    
}


- (void)showWordTwo
{
    self.label3 = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH+30, 80, WIDTH, 30)];
    [self.scrollView addSubview:self.label3];
    [_label3 release];
    self.label3.text = @"无论何时何地";
    self.label3.font = [UIFont systemFontOfSize:20];
    self.label3.alpha = 0;
    
    self.label4 = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH+50, 180, WIDTH, 30)];
    [self.scrollView addSubview:self.label4];
    [_label4 release];
    self.label4.text = @"我们与您同在......";
    self.label4.font = [UIFont systemFontOfSize:20];
    self.label4.alpha = 0;
    
}

- (void)pushController
{
    [[AVSingleton shareSingleton] goTo];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
